package libase.web.jsf.entity.converter;

import java.math.BigDecimal;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.convert.Converter;
import javax.faces.convert.FacesConverter;
import javax.inject.Named;
import libase.entity.Author;

/**
 *
 * @author aspr0
 */
@Named
//@FacesConverter(forClass = Author.class)
public class AuthorConverter implements Converter
{
    @Override
    public Object getAsObject(FacesContext context, UIComponent component, String value)
    {
        BigDecimal id = new BigDecimal(value);
        Author a = new Author(id);

        return a;
    }

    @Override
    public String getAsString(FacesContext context, UIComponent component, Object value)
    {
        Author a = (Author) value;

        return a.getId().toString();
    }
}
